import { useRouter } from "next/navigation";
import { QueryClient, useMutation, useQuery } from "@tanstack/react-query";
import { useForm } from "react-hook-form";
import { userControllerGetMe } from "@/shared/api/api.user";

export function useGetCurrentUser() {
    const queryClient = new QueryClient

    const { isLoading, error, data, isSuccess, refetch } =
        useQuery(
            {
                queryKey: ['query-getme'],
                queryFn: userControllerGetMe,
            }, queryClient
        )

    const errorMessage = error ? "Get user failed" : undefined;
    return {
        errorMessage,
        isLoading,
        isSuccess,
        refetch,
        user: data,
    };
}